import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:material_collection_app/utils/utils.dart';

class CheckDialogDetail extends StatefulWidget {
  final Map item;

  CheckDialogDetail({
    Key key,
    this.item,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() => CheckDialogDetailState();
}

class CheckDialogDetailState extends State<CheckDialogDetail> {
  TextEditingController _remarkController = new TextEditingController();

  @override
  void initState() {
    super.initState();
  }

  Widget _buildDialogHead(title) {
    return Container(
      height: 80.w,
      decoration: BoxDecoration(
          color: Utils.hexToColor('#F7F7F7'),
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(12.w), topRight: Radius.circular(12.w))),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Container(
            margin: EdgeInsets.only(left: 31.w),
            child: Text(title,
                style: TextStyle(
                    color: Utils.hexToColor('#333333'),
                    fontSize: 16,
                    fontWeight: FontWeight.bold)),
          ),
          InkWell(
            onTap: () {
              Navigator.of(context).pop();
            },
            child: Container(
              padding: EdgeInsets.fromLTRB(30.w, 24.w, 30.w, 24.w),
              alignment: Alignment.topRight,
              child: Image.asset(
                'assets/dialog_close.png',
                width: 36.w,
              ),
            ),
          )
        ],
      ),
    );
  }

  Widget _buildRow(String title, String number) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 13),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Text(
            title,
            style: TextStyle(color: Utils.hexToColor('#808080'), fontSize: 14),
          ),
          Container(
            width: 450.w,
            alignment: Alignment.centerRight,
            child: Text(number.toString() == 'null' ? '' : number.toString(),
                style: TextStyle(
                    color: Utils.hexToColor('#333333'), fontSize: 15)),
          )
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false);

    return Container(
        width: 700.w,
        height: 1161.w,
        decoration:
            BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(100))),
        child: Column(
          children: <Widget>[
            _buildDialogHead('物资信息'),
            Expanded(
              flex: 1,
              child: SingleChildScrollView(
                child: Container(
                    padding: EdgeInsets.fromLTRB(20, 0, 20, 20),
                    child: Column(
                      children: <Widget>[
                        _buildRow('RFID', widget.item['rfid_code']),
                        _buildRow('物资编号', widget.item['code']),
                        _buildRow('物资名称', widget.item['goods_name']),
                        _buildRow('规格/型号', widget.item['--']),
                        _buildRow('物资分类', widget.item['goodsType__type_name']),
                        _buildRow('数量', widget.item['real_qty'].toString()),
                        _buildRow('计量单位', widget.item['goods_unit']),
                        _buildRow('所在仓库', widget.item['store__store_name']),
                        _buildRow(
                            '所在库区', widget.item['storeLibrary__library_name']),
                        _buildRow(
                            '所在库位', widget.item['storeDetail__detail_code'])
                      ],
                    )),
              ),
            ),
          ],
        ));
  }
}
